package com.laima.basic.controller;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.laima.basic.Exception.Response;
import com.laima.basic.model.SysNotice;
import com.laima.basic.service.SysNoticeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.slf4j.LoggerFactory;

import javax.validation.constraints.Max;
import java.util.List;

/**
 * @program: backend-server
 * @description: 通知公告
 * @author: T
 * @create: 2021-03-25 10:02
 **/

@Api(tags = {"通知公告管理"})
@RestController
@RequestMapping("notice")
public class SysNoticeController {

    private Logger logger =  LoggerFactory.getLogger(SysNoticeController.class);

    @Autowired
    private SysNoticeService sysNoticeService;


    @ApiOperation(value = "selectNoticeList", notes = "查询公告列表 ")
    @RequestMapping(value = "selectNoticeList", method = RequestMethod.POST)
    public Response selectNoticeList(@RequestBody(required=false) SysNotice sysNotice) {
        List<SysNotice> list =sysNoticeService.selectNoticeList(sysNotice);
        return Response.ok(list);
    }

    @ApiOperation(value = "selectNoticeById", notes = "按照id查询公告信息")
    @RequestMapping(value = "selectNoticeById", method = RequestMethod.GET)
    public Response selectNoticeById(@RequestParam("noticeId") Long noticeId) {
        return Response.ok(sysNoticeService.selectNoticeById(noticeId));
    }

    @ApiOperation(value = "insertNotice", notes = "新增公告信息")
    @RequestMapping(value = "insertNotice", method = RequestMethod.POST)
    public Response insertNotice(@RequestBody SysNotice sysNotice) {
        return Response.ok(sysNoticeService.insertNotice(sysNotice));
    }

    @ApiOperation(value = "updateNotice", notes = "修改公告信息")
    @RequestMapping(value = "updateNotice", method = RequestMethod.POST)
    public Response updateNotice(@RequestBody SysNotice sysNotice) {
        return Response.ok(sysNoticeService.updateNotice(sysNotice));
    }

    @ApiOperation(value = "deleteNoticeById", notes = "按照id删除公告信息")
    @RequestMapping(value = "deleteNoticeById", method = RequestMethod.GET)
    public Response deleteNoticeById(@RequestParam("noticeId") Long noticeId) {
        return Response.ok(sysNoticeService.deleteNoticeById(noticeId));
    }

    @ApiOperation(value = "deleteNoticeByIds", notes = "批量删除公告信息")
    @RequestMapping(value = "deleteNoticeByIds", method = RequestMethod.GET)
    public Response deleteNoticeByIds(@PathVariable Long[] noticeId) {
        return Response.ok(sysNoticeService.deleteNoticeByIds(noticeId));
    }

}
